package com.oa.android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.oa.android.R;
import com.oa.android.entry.RicType;

import java.util.List;

/**
 * 日程类型
 * Created by zouqh on 2016/6/19.
 */
public class RicTypeAdapter extends BaseAdapter {
    private Context context;
    private List<RicType> typeList;
    public RicTypeAdapter(Context context, List<RicType> typeList){
        this.context=context;
        this.typeList=typeList;
    }
    @Override
    public int getCount() {
        return typeList.size();
    }

    @Override
    public Object getItem(int position) {
        return typeList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHodler viewHodler;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_text,null);
            viewHodler=new ViewHodler();
            viewHodler.textView=(TextView)convertView.findViewById(R.id.name);
            convertView.setTag(viewHodler);
        }else {
            viewHodler= (ViewHodler) convertView.getTag();
        }
        viewHodler.textView.setText(typeList.get(position).getSNAME()+"");
        return convertView;
    }

    class ViewHodler{
        TextView textView;
    }
}
